<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>userInfo</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.2.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/jquery-easyui-1.2.3/themes/icon.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.2.3/jquery-1.4.4.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.2.3/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/jquery-easyui-1.2.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#backId").click(function() {
				location.replace("${pageContext.request.contextPath}/");
			});
			$("#saveId").click(function() {				
				var r = $('#userForm').form('validate');
				if(!r) {
					return false;
				}
				$.post("${pageContext.request.contextPath}/user/registerUser",$("#userForm").serializeArray(),function(data){ 
					$('#tt').tabs('close', '用户信息');					
					if($.trim(data) == "注册成功！"){
							location.replace('${pageContext.request.contextPath}/');
						} else {
							$("input").val("");
					}						
				});
			});			
		});
		$.extend($.fn.validatebox.defaults.rules, {
  		 	mobile: {
		        validator: function (value) {
		        	var reg = /^1[3|4|5|8|9]\d{9}$/;
		            return reg.test(value);
		        },
		        message: '输入手机号码格式不准确.'
	    	}
	   });
	   $(function(){
			$('#userForm input').each(function () {
	            if ($(this).attr('required') || $(this).attr('validType'))
		                $(this).validatebox();
		    });	
	   });
	   
	   $(function(){
	   		var parentId = $('#parentId').combobox({
				valueField:'tpId', //值字段
			    textField:'tpName', //显示的字段
			    url:'${pageContext.request.contextPath}/product/parentProductAll',
			    panelHeight:'auto',
				required :true ,//不可编辑，只能选择
				onSelect:function(record){
					tpId.combobox({
						disabled:false,
						valueField:'tpId', //值字段
					    textField:'tpName', //显示的字段
					    url:'${pageContext.request.contextPath}/product/childProductAll?tpId='+record.tpId,
					    panelHeight:'auto',
					    required :true 
					}).combobox('clear');
				}
			});
			var tpId = $('#tpId').combobox({
						disabled:false,
						valueField:'tpId', //值字段
					    textField:'tpName', //显示的字段
					    url:'${pageContext.request.contextPath}/product/childProductAll?tpId='+parentId.val(),
					    panelHeight:'auto',
					    required :true
			});
	   });
	   
	   $.extend($.fn.validatebox.defaults.rules, {
  		 	userpwd: {
		        validator: function (value) {		        
		            return $("input[name=userPwd]").val()==value;
		        },
		        message: '两次输入的密码不一致.'
	    	},
	    	idcard: {
		        validator: function (value) {
		        	if(isNaN(value)){
		        		return false;
		        	}
		            return true;
		        },
		        message:'请输入正确的身份证号码'
		    }
	   });
	   $(function(){
			$('#userForm input').each(function () {
	            if ($(this).attr('required') || $(this).attr('validType'))
		                $(this).validatebox();
		    });	
	   });
	   
	</script>
	<style type="text/css">
		input{
			width:200px;
			border:1px solid #ccc;
			padding:2px;
		}
	</style>
  </head>
  <body>
  <center>
  <div id="show" class="wrap">
	<form id="userForm" action="${pageContext.request.contextPath}/user/editUserInfo" method="post">
	<table id="userInfoId" style="font-size: 13px">
		<tr>
			<td colspan="2" align="center"><h2>用户注册</h2></td>
		</tr>
		<tr>
			<td width="100px">登录：</td>
			<td width="100px"><input type="text"  class="easyui-validatebox"  validType="remote['${pageContext.request.contextPath}/user/checkLoginId','loginId']" name="loginId" required="true" invalidMessage="登录名已存在"/></td>
		</tr>
		<tr>
			<td width="100px">密码：</td>
			<td><span id="userPwd"><input type="password" name="userPwd" class="easyui-validatebox"  required="true" /></span></td>			
		</tr>
		<tr>
			<td width="100px">确认密码：</td>
			<td><span id="userPwd2"><input type="password" name="userPwd2" validType="userpwd" class="easyui-validatebox"  required="true" /></span></td>			
		</tr>
		<tr>
			<td width="100px">真实姓名：</td>
			<td><span id="userName"><input type="text" name="userName"  class="easyui-validatebox"  required="true"  /></span></td>			
		</tr>
		<tr>
			<td width="100px">性别：</td>
			<td width="100px"><span id="sex"><select name="sex" style="border:1px solid #ccc;padding: 2px"><option value="男" >男</option><option value="女" >女</option></select></span></td>
		</tr>
		<tr>
			<td width="100px">出生日期：</td>
			<td><span id="birthday"><input type="text"  name="birthday"  class="easyui-validatebox"   required="true" onClick="WdatePicker()"/></span></td>
		</tr>
		<tr>
			<td width="100px">等级：</td>
			<td>
				<input type="text" id="parentId" name="parentId" style="width: 97px;"  class="easyui-validatebox" />
				<input type="text" id="tpId" name="tpId" style="width: 97px;" class="easyui-validatebox"  />
			</td>
		</tr>
		<tr>
			<td width="100px">电子邮件：</td>
			<td width="100px"><span id="email"><input type="text" class="easyui-validatebox" validType="email" name='email' /></span></td>
		</tr>
		<tr>
			<td width="100px">身份证：</td>
			<td><span id="code"><input type="text" validType="idcard" class="easyui-validatebox" name="identityCode" required="true"  /></span></td>
		</tr>
		<tr>
			<td width="100px">地址：</td>
			<td width="100px"><span id="address"><input type="text" class="easyui-validatebox" name="address" /></span></td>
		</tr>
		<tr>
			<td width="100px">手机号码：</td>
			<td><span id="phone"><input type="text" class="easyui-validatebox"  validType="mobile" name="mobile" /></span></td>
		</tr>
		<tr height="20px">
			<td>
			</td>
			<td>
			</td>
		</tr>
		<tr>
			<td align="center" colspan="2">
				<a id="backId" class="easyui-linkbutton"
							iconCls="icon-back">返回</a>
			<span style="width: 56px"></span>
				<a id="saveId" class="easyui-linkbutton"
							iconCls="icon-save">注册</a>
			</td>
		</tr>
	</table>
	</form>
</div>
</center>
  </body>
</html>
